const tools = require('../../models/tools')

module.exports = (app, router) => {
    const Tool = require('../../models/tools')
    const { requestResult } = require('../../plugins/index')

    router.post('/addTools', async (req, res) => {
        let data = await Tool.create(req.body)
        res.send(requestResult(data))
    })

    router.post('/updateTools', async (req, res) => {
        let data = await Tool.findByIdAndUpdate(req.body._id, req.body)
        res.send(requestResult(data))
    })

    router.get('/findTools', async (req, res) => {
        let data = await tools.find()
        res.send(requestResult(data))
    })
    app.use('/admin/api', router)
}